package com.firebird.app.fekpsl.ui.activity.classroom

import android.content.Context
import android.content.Intent
import androidx.appcompat.app.AppCompatActivity
import android.os.Bundle
import com.firebird.app.fekpsl.R
import com.firebird.app.fekpsl.constant.Constant
import com.firebird.app.fekpsl.ui.activity.exam.ExamActivity
import com.firebird.app.fekpsl.utils.ImageLoader
import kotlinx.android.synthetic.main.classroom_question_practice_mark.*
import kotlinx.android.synthetic.main.exam_paper.*

class QuestionPracticeMarkActivity : AppCompatActivity() {
    private var pf_examSubjectId=0
    private var pf_questionTotalNum=0;
    companion object {
        fun start(context: Context?, practiceSubjectId: Int, questionTotalNum: Int, practiceTitle: String, bundle: Bundle? = null) {
            Intent(context, QuestionPracticeMarkActivity::class.java).run {
                putExtra(Constant.EXAM_SUBJECT_ID_KEY, practiceSubjectId)
                putExtra(Constant.EXAM_PAPER_QUESTION_TOTAL_NUM_KEY, questionTotalNum)
                putExtra(Constant.EXAM_PAPER_NAME_KEY, practiceTitle)
                context?.startActivity(this, bundle)
            }
        }
    }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        setContentView(R.layout.classroom_question_practice_mark)

        intent.extras?.let {
            pf_examSubjectId = it.getInt(Constant.EXAM_SUBJECT_ID_KEY, -1)
            tv_question_practice_title.text = it.getString(Constant.EXAM_PAPER_NAME_KEY, "")
            tv_question_practice_user_name.text = it.getString(Constant.EXAM_USER_NAME_KEY, "")

            val user_avatar = it.getString(Constant.EXAM_USER_AVATAR_KEY, "")
            if (user_avatar.isNotEmpty()) {
                ImageLoader.load(this, user_avatar, iv_question_practice_user_avatar)
            } else {
                iv_question_practice_user_avatar.setImageDrawable(resources.getDrawable(R.drawable.icon_default_user))
            }
        }
    }
}